﻿using ch07.binary.module;

namespace ch07.binary.wasm_reader
{
    public partial struct WasmReader
    {
        // data sec
        private Data[] ReadDataSec()
        {
            var vec = new Data[ReadVarU32()];
            for (var i = 0; i < vec.Length; i++)
            {
                vec[i] = ReadData();
            }

            return vec;
        }

        private Data ReadData()
        {
            return new()
            {
                Mem = ReadVarU32(),
                Offset = ReadExpr(),
                Init = ReadBytes(),
            };
        }
    }
}